from rest_framework.serializers import ModelSerializer
from login.serializers import UserModelSerializer
from goods.serializers import ProductSerializer
from orders.models import Order


class OrderSerializer(ModelSerializer):
    # 修复1: 移除source参数，直接序列化整个用户对象
    order_user = UserModelSerializer(read_only=True)

    # 修复2: 移除source参数，直接序列化整个产品对象
    order_product = ProductSerializer(read_only=True)

    class Meta:
        model = Order
        fields = '__all__'
